<template>
    <span v-if="item">{{ item.caption }}</span>
</template>

<script>
export default {
    name: 'TnxelEnumView',
    props: {
        type: {
            type: String,
            required: true,
        },
        subtype: String,
        itemKey: {
            type: String,
            required: true,
        },
        app: {
            type: String,
            default: () => window.tnx.componentDefaultApp, // 设置为方法以延时加载，确保更改的值生效
        },
    },
    data() {
        return {
            item: null,
        };
    },
    mounted() {
        window.tnx.app.rpc.resolveEnumType(this.type, this.subtype, {
            app: this.app,
        }).then(enumType => {
            this.item = enumType.items.find(item => item.key === this.itemKey);
        });
    },
    methods: {}
}
</script>

<style scoped>

</style>
